package ocm.oh.ds;

public class MainDS {

    /**
     * @param args
     */
    public static void main(String[] args) {

        DS ds = new DS(6);                                        
        SolutionState solutionState = ds.doDumbSearch(10000000);
        
        if(solutionState.isSolution()) {
            System.out.println("Found solution!");
        }        
        System.out.println("Time spent (in ms) :" + solutionState.getRunTimeInMs());
        System.out.println("Nr of moves: " + solutionState.getMoves());
       	QueenGui gui = new QueenGui("Solution found?", solutionState.getQueens());
   
        
//        SolutionState solutionCloseToOneMinute = getSolutionCloseToTime(60000);
//        if(solutionCloseToOneMinute.isSolution()) {
//            System.out.println("Able to solve K = " + solutionCloseToOneMinute.getK() + " in " + solutionCloseToOneMinute.getRunTimeInMs() + " ms");
//        }
    }
    
    public static void test() {
        for(int k=0; k < 400; k++) {
            DS ds = new DS(k);
            SolutionState solution = ds.doDumbSearch(1000000000);
            if(solution.isSolution()) {
                System.out.println("Found solution for K = " + k + " in " + solution.getRunTimeInMs() + " ms");
            }
        }
    }
    
    public static SolutionState getSolutionCloseToTime(long closeToMs) {    	
        int k = 1050;
        long timeSpent = 0;
        int runs = 1; //
        long averageRunTime = 0; //
        SolutionState solution = null;
        while(averageRunTime < 120000) {
        	long timeForCurrentK = 0;
        	for(int i=0;i<runs;i++){
	            DS ds = new DS(k);
	            solution = ds.doDumbSearch(1000000000);
	            if(solution.isSolution()) {
	                //System.out.println("Found solution for K = " + k + " in " + solution.getRunTimeInMs() + " ms");
	            }
	            timeForCurrentK += solution.getRunTimeInMs();
	            //timeSpent = solution.getRunTimeInMs();   
        	}
        	long averageForCurrentK = timeForCurrentK / runs;
        	System.out.println("Solved K = " +k+ ", "+runs+ " times. Average time spent: " +averageForCurrentK+ " ms" );
            k+=50;
        }
        return solution;
    }
}
